import 'package:dss_base/dss_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo_test/module/get_material_widget_init.dart';
import 'package:flutter_demo_test/module/http_init.dart';
import 'package:flutter_demo_test/module/other_init.dart';
import 'package:flutter_demo_test/module/refresh_init.dart';
import 'package:flutter_demo_test/module/screen_init.dart';
import 'package:flutter_demo_test/module/toast_init.dart';
import 'package:flutter_demo_test/main_page.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({super.key}) {
    List<ModuleInitProvider> list = [
      // 网络
      HttpInit(),
      // 下拉刷新
      RefreshInit(),
      // 其他一些杂七杂八的
      OtherInit(),
    ];
    for (var element in list) {
      element.init();
    }
  }

  @override
  Widget build(BuildContext context) {
    List<WidgetInitProvider> list = [
      // 主界面
      GetMaterialWidgetInit(),
      // Toast
      ToastInitProvider(),
      // 屏幕适配
      ScreenInit(),
    ];
    Widget home = const MainPage();
    for (var element in list) {
      home = element.init(home);
    }
    return home;
  }
}
